<?php
	/*
	 * 引用一个类的属性和方法就使用 -> 符号	
	 * -> 这个箭头也可以是调用类中的函数
	 */
	header("Content-Type: text/html;charset=utf-8");
	
	$servername = "localhost";
	$username = "root";
	$password = "456789";
	$dbname = "mysqlstudy";

	//创建连接
	$conn = new mysqli($servername, $username, $password, $dbname);
	//检测连接
	if($conn -> connect_error){
		die("连接失败：" . $conn -> connect_error);
	}
	//设置编码，防止中文乱码
	mysqli_query($conn, "set names utf8");

	$sql = "SELECT id,oid,tel,name,content,cdate FROM tp_order WHERE id<5 ORDER BY id";
	$result = $conn -> query($sql);

//从结果集中取得一行作为数字数组或关联数组
$obj = $result -> fetch_array(MYSQLI_ASSOC);  //返回关联数组
/*
 * Array ( [id] => 1 [oid] => 19 [tel] => 212 [name] => 央视网消息： [content] => 2 [cdate] => 1529346541 )
 */

//$obj1 = $result -> fetch_array(MYSQLI_NUM);  //返回数字数组
/*
 * Array ( [0] => 1 [1] => 19 [2] => 212 [3] => 央视网消息： [4] => 2 [5] => 1529346541 )
 */

//$obj2 = $result -> fetch_array(MYSQLI_BOTH); //都返回
/*
 * Array ( [0] => 1 [id] => 1 [1] => 19 [oid] => 19 [2] => 212 [tel] => 212 [3] => 央视网消息： [name] => 央视网消息： [4] => 2 [content] => 2 [5] => 1529346541 [cdate] => 1529346541 )
 */

//$obj3 = $result -> fetch_array();
/*
 * Array ( [0] => 1 [id] => 1 [1] => 19 [oid] => 19 [2] => 212 [tel] => 212 [3] => 央视网消息： [name] => 央视网消息： [4] => 2 [content] => 2 [5] => 1529346541 [cdate] => 1529346541 )
 */


	print_r ($obj);
	//print_r ($obj1);
	//print_r ($obj2);
	//print_r ($obj3);
	
	
?>